package com.library.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.library.bean.User;
import com.library.service.BookService;
import com.library.service.impl.BookServiceImpl;

@WebServlet("/showBook.do")
public class ShowBookServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		BookService bookService = new BookServiceImpl();
		int pageNum = request.getParameter("pageNum") == null ? 1: Integer.parseInt(request.getParameter("pageNum"));
		int pageSize = request.getParameter("pageSize") == null ? 5: Integer.parseInt(request.getParameter("pageSize"));
		request.setAttribute("page", bookService.getAllBook(pageNum, pageSize));
		request.getRequestDispatcher("book.jsp").forward(request,response);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
	
}
